<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/base.jsp"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>首页</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="${basePath}/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="${basePath}/lib/font-awesome-4.7.0/css/font-awesome.min.css" media="all">
    <link rel="stylesheet" href="${basePath}/css/public.css" media="all">
    <style>
        .top-panel {
            border: 1px solid #eceff9;
            border-radius: 5px;
            text-align: center;
        }
        .top-panel > .layui-card-body{
            height: 60px;
        }
        .top-panel-number{
            line-height:60px;
            font-size: 30px;
            border-right:1px solid #eceff9;
        }
        .top-panel-tips{
            line-height:30px;
            font-size: 12px
        }
        .layui-top-box {padding:40px 20px 20px 20px;color:#fff}
        .panel {margin-bottom:17px;background-color:#fff;border:1px solid transparent;border-radius:3px;-webkit-box-shadow:0 1px 1px rgba(0,0,0,.05);box-shadow:0 1px 1px rgba(0,0,0,.05)}
        .panel-body {padding:15px}
        .panel-title {margin-top:0;margin-bottom:0;font-size:14px;color:inherit}
        .label {display:inline;padding:.2em .6em .3em;font-size:75%;font-weight:700;line-height:1;color:#fff;text-align:center;white-space:nowrap;vertical-align:baseline;border-radius:.25em;margin-top: .3em;}
        .layui-red {color:red}
        .main_btn > p {height:40px;}
    </style>
</head>
<body>
<!--<div class="layuimini-container">-->
<div class="layuimini-main">
    <div class="layuimini-main layui-top-box">
        <div class="layui-row layui-col-space10">

            <div class="layui-col-md4">
                <div class="col-xs-6 col-md-3">
                    <div class="panel layui-bg-cyan">
                        <div class="panel-body">
                            <div class="panel-title">
                                <span class="label pull-right layui-bg-blue">实时</span>
                                <h5>学生现有成绩数</h5><h1 class="no-margins">${data_exam}</h1>
                            </div>
                            <div class="panel-content">
                                <small>全部课程总数</small>
                                <div class="stat-percent font-bold text-gray">${data_allExam}</div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="layui-col-md4">
                <div class="col-xs-6 col-md-3">
                    <div class="panel layui-bg-blue">
                        <div class="panel-body">
                            <div class="panel-title">
                                <span class="label pull-right layui-bg-cyan">实时</span>
                                <h5>学生考试均分</h5><h1 class="no-margins">${data_avg}</h1>
                            </div>
                            <div class="panel-content">
                                <small>全体学生均分</small>
                                <div class="stat-percent font-bold text-gray">${data_allAvg}</div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="layui-col-md4">
                <div class="col-xs-6 col-md-3">
                    <div class="panel layui-bg-red">
                        <div class="panel-body">
                            <div class="panel-title">
                                <span class="label pull-right layui-bg-green">实时</span>
                                <h5>不及格数统计</h5><h1 class="no-margins">${data_fail}</h1>
                            </div>
                            <div class="panel-content">
                                <small>成绩总数</small>
                                <div class="stat-percent font-bold text-gray">${data_exam}</div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="layui-row layui-col-space15">
        <div class="layui-col-xs12 layui-col-md12">
            <div id="echarts-records" style="background-color:#ffffff;min-height:400px;padding: 10px"></div>
        </div>
    </div>

</div>
<!--</div>-->
<script src="${basePath}/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script src="${basePath}/js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script>
    layui.use(['layer', 'echarts'], function () {
        var $ = layui.jquery,
            layer = layui.layer,
            echarts = layui.echarts;

        /**
         * 报表功能
         */
        var echartsRecords = echarts.init(document.getElementById('echarts-records'), 'walden');

        var optionRecords = {
            title: {
                text: '学生成绩变化图',
                left: 'center'
            },
            tooltip: {//提示气泡
                trigger: 'axis',
                axisPointer: {
                    type: 'line',
                    label: {
                        backgroundColor: '#6a7985'
                    }
                }
            },
            grid: {
                left: '3%',
                right: '4%',
                bottom: '3%',
                containLabel: true
            },
            xAxis: [
                {
                    type: 'category',
                    name:'试卷名称',
                    boundaryGap: false,
                    data: []
                }
            ],
            yAxis: [
                {
                    type: 'value',
                    name: '分数',
                    nameTextStyle: {
                        fontSize:12
                    }
                }
            ],
            series: [
                {
                    name: '成绩',
                    type: 'line',
                    stack: '总量',
                    label: {
                        normal: {
                            show: true,
                            position: 'top'
                        }
                    },
                    areaStyle: {},
                    data: []
                }
            ]
        };
        //加载动画
        echartsRecords.showLoading();
        echartsRecords.setOption(optionRecords);
        //发送ajax异步请求动态加载图表数据
        var xNames = [];
        var yScores = [];
        $.ajax({
            url:'${basePath}/stu/scoreLineJson',
            type:'get',
            dataType:'json',
            success:function(res){
                if(res.code===0){
                    //获取数据集合
                    var data = res.data;
                    //遍历数据封装x轴坐标及图表数据
                    for(var i=0;i<data.length;i++){
                        /*通过后台查找数据，横向为课程名称，纵向为分数信息*/
                        xNames.push(data[i].name);
                        yScores.push(data[i].score);
                    }
                    //关闭加载动画
                    echartsRecords.hideLoading();
                    //将数据加载到图表中
                    echartsRecords.setOption({
                        xAxis: {
                            /*横向的课程名称*/
                            data: xNames
                        },
                        series: [{
                            /*纵向的分数信息*/
                            data: yScores
                        }]
                    })
                }else{
                    layer.msg(res.msg,function (){
                        //关闭加载动画
                        echartsRecords.hideLoading();
                    });
                }
            }

        })
        // echarts 窗口缩放自适应
        window.onresize = function () {
            echartsRecords.resize();
        }

    });
</script>
</body>
</html>
